package com.biz.primus.ms.depot.api;

import com.biz.primus.common.vo.SpringPageVO;
import com.biz.primus.model.depot.vo.DepotDeliverPriceListReqVo;
import com.biz.primus.model.depot.vo.DepotDeliverPriceRespVo;
import com.biz.primus.model.depot.vo.DepotDeliverPriceUpdateVo;
import com.biz.primus.ms.base.api.BaseApiController;
import com.biz.primus.ms.depot.service.DepotDeliverPriceService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * DepotDeliverPriceController
 *
 * @author JKLiues
 * @date 2017年10月31日
 */
@RestController
@RequestMapping("soa/depotDeliverPriceService")
public class DepotDeliverPriceController extends BaseApiController {

    private final DepotDeliverPriceService depotDeliverPriceService;

    @Autowired
    public DepotDeliverPriceController(DepotDeliverPriceService depotDeliverPriceService) {
        this.depotDeliverPriceService = depotDeliverPriceService;
    }

    @ApiOperation(value = "更新门店起送价配置")
    @PostMapping("updateDeliverPrice")
    public void updateDeliverPrice(@RequestBody DepotDeliverPriceUpdateVo reqVo) {
        depotDeliverPriceService.updateDeliverPrice(reqVo);
    }

    @ApiOperation("门店起送价配置列表")
    @PostMapping("pageResult")
    public SpringPageVO<DepotDeliverPriceRespVo> pageResult(@RequestBody DepotDeliverPriceListReqVo reqVo) {
        return depotDeliverPriceService.pageResult(reqVo);
    }

    @ApiOperation("根据门店编码获取门店起送价配置详情(Mysql)")
    @GetMapping("getDepotDeliverPriceFdb")
    public DepotDeliverPriceRespVo getDepotDeliverPriceFdb(@ApiParam(value = "门店编码") @RequestParam("depotCode") String depotCode) {
        return depotDeliverPriceService.getDepotDeliverPriceFdb(depotCode);
    }

    @ApiOperation("根据门店编码获取门店起送价配置详情(Redis)")
    @GetMapping("getDepotDeliverPriceFRdb")
    public DepotDeliverPriceRespVo getDepotDeliverPriceFRdb(@ApiParam(value = "门店编码") @RequestParam("depotCode") String depotCode) {
        return depotDeliverPriceService.getDepotDeliverPriceFRdb(depotCode);
    }

}